﻿#region Using Directives
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Web.UI;
using System.Web.UI.Design;

using EcomProduct.Entities;
using EcomProduct.Data;
using EcomProduct.Data.Bases;
#endregion

namespace EcomProduct.Web.Data
{
	/// <summary>
	/// Represents the DataRepository.ProductProvider object that provides
	/// data to data-bound controls in multi-tier Web application architectures.
	/// </summary>
	[Designer(typeof(ProductDataSourceDesigner))]
	public class ProductDataSource : ProviderDataSource<Product, ProductKey>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the ProductDataSource class.
		/// </summary>
		public ProductDataSource() : base(DataRepository.ProductProvider)
		{
		}

		#endregion Constructors
		
		#region Properties
		
		/// <summary>
		/// Gets a reference to the ProductDataSourceView used by the ProductDataSource.
		/// </summary>
		protected ProductDataSourceView ProductView
		{
			get { return ( View as ProductDataSourceView ); }
		}
		
		/// <summary>
		/// Gets or sets the name of the method or function that
		/// the ProductDataSource control invokes to retrieve data.
		/// </summary>
		public ProductSelectMethod SelectMethod
		{
			get
			{
				ProductSelectMethod selectMethod = ProductSelectMethod.GetAll;
				Object method = ViewState["SelectMethod"];
				if ( method != null )
				{
					selectMethod = (ProductSelectMethod) method;
				}
				return selectMethod;
			}
			set { ViewState["SelectMethod"] = value; }
		}

		#endregion Properties
		
		#region Methods

		/// <summary>
		/// Creates a new instance of the ProductDataSourceView class that is to be
		/// used by the ProductDataSource.
		/// </summary>
		/// <returns>An instance of the ProductDataSourceView class.</returns>
		protected override BaseDataSourceView<Product, ProductKey> GetNewDataSourceView()
		{
			return new ProductDataSourceView(this, DefaultViewName);
		}
		
		/// <summary>
        /// Creates a cache hashing key based on the startIndex, pageSize and the SelectMethod being used.
        /// </summary>
        /// <param name="startIndex">The current start row index.</param>
        /// <param name="pageSize">The current page size.</param>
        /// <returns>A string that can be used as a key for caching purposes.</returns>
		protected override string CacheHashKey(int startIndex, int pageSize)
        {
			return String.Format("{0}:{1}:{2}", SelectMethod, startIndex, pageSize);
        }
		
		#endregion Methods
	}
	
	/// <summary>
	/// Supports the ProductDataSource control and provides an interface for
	/// data-bound controls to perform data operations with business and data objects.
	/// </summary>
	public class ProductDataSourceView : ProviderDataSourceView<Product, ProductKey>
	{
		#region Declarations

		#endregion Declarations
		
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the ProductDataSourceView class.
		/// </summary>
		/// <param name="owner">A reference to the ProductDataSource which created this instance.</param>
		/// <param name="viewName">The name of the view.</param>
		public ProductDataSourceView(ProductDataSource owner, String viewName)
			: base(owner, viewName)
		{
		}
		
		#endregion Constructors
		
		#region Properties

		/// <summary>
		/// Gets a strongly-typed reference to the Owner property.
		/// </summary>
		internal ProductDataSource ProductOwner
		{
			get { return Owner as ProductDataSource; }
		}

		/// <summary>
		/// Gets or sets the name of the method or function that
		/// the DataSource control invokes to retrieve data.
		/// </summary>
		internal ProductSelectMethod SelectMethod
		{
			get { return ProductOwner.SelectMethod; }
			set { ProductOwner.SelectMethod = value; }
		}

		/// <summary>
		/// Gets a strongly typed reference to the Provider property.
		/// </summary>
		internal ProductProviderBase ProductProvider
		{
			get { return Provider as ProductProviderBase; }
		}

		#endregion Properties
		
		#region Methods
		
		/// <summary>
		/// Gets a collection of Entity objects based on the value of the SelectMethod property.
		/// </summary>
		/// <param name="count">The total number of rows in the DataSource.</param>
		/// <returns>A collection of Entity objects.</returns>
		protected override IList<Product> GetSelectData(out int count)
		{
			Hashtable values = CollectionsUtil.CreateCaseInsensitiveHashtable(GetParameterValues());
			Hashtable customOutput = CollectionsUtil.CreateCaseInsensitiveHashtable();
			IList<Product> results = null;
			Product item;
			count = 0;
			
			System.String _alias_nullable;
			System.Boolean _isDisabled;
			System.Boolean _isRemoved;
			System.Int64 _id;
			System.String _language;
			System.Int64 _originalId;
			System.String _menuAlias_nullable;
			System.Int64 _menuId;

			switch ( SelectMethod )
			{
				case ProductSelectMethod.Get:
					ProductKey entityKey  = new ProductKey();
					entityKey.Load(values);
					item = ProductProvider.Get(GetTransactionManager(), entityKey);
					results = new TList<Product>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				case ProductSelectMethod.GetAll:
                    results = ProductProvider.GetAll(GetTransactionManager(), StartIndex, PageSize, out count);
                    break;
				case ProductSelectMethod.GetPaged:
					results = ProductProvider.GetPaged(GetTransactionManager(), WhereClause, OrderBy, PageIndex, PageSize, out count);
					break;
				case ProductSelectMethod.Find:
					if ( FilterParameters != null )
						results = ProductProvider.Find(GetTransactionManager(), FilterParameters, OrderBy, StartIndex, PageSize, out count);
					else
						results = ProductProvider.Find(GetTransactionManager(), WhereClause, StartIndex, PageSize, out count);
                    break;
				// PK
				case ProductSelectMethod.GetById:
					_id = ( values["Id"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["Id"], typeof(System.Int64)) : (long)0;
					item = ProductProvider.GetById(GetTransactionManager(), _id);
					results = new TList<Product>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				// IX
				case ProductSelectMethod.GetByAlias:
					_alias_nullable = (System.String) EntityUtil.ChangeType(values["Alias"], typeof(System.String));
					item = ProductProvider.GetByAlias(GetTransactionManager(), _alias_nullable);
					results = new TList<Product>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				case ProductSelectMethod.GetByAliasIsDisabled:
					_alias_nullable = (System.String) EntityUtil.ChangeType(values["Alias"], typeof(System.String));
					_isDisabled = ( values["IsDisabled"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsDisabled"], typeof(System.Boolean)) : false;
					item = ProductProvider.GetByAliasIsDisabled(GetTransactionManager(), _alias_nullable, _isDisabled);
					results = new TList<Product>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				case ProductSelectMethod.GetByAliasIsDisabledIsRemoved:
					_alias_nullable = (System.String) EntityUtil.ChangeType(values["Alias"], typeof(System.String));
					_isDisabled = ( values["IsDisabled"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsDisabled"], typeof(System.Boolean)) : false;
					_isRemoved = ( values["IsRemoved"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsRemoved"], typeof(System.Boolean)) : false;
					item = ProductProvider.GetByAliasIsDisabledIsRemoved(GetTransactionManager(), _alias_nullable, _isDisabled, _isRemoved);
					results = new TList<Product>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				case ProductSelectMethod.GetByAliasIsRemoved:
					_alias_nullable = (System.String) EntityUtil.ChangeType(values["Alias"], typeof(System.String));
					_isRemoved = ( values["IsRemoved"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsRemoved"], typeof(System.Boolean)) : false;
					results = ProductProvider.GetByAliasIsRemoved(GetTransactionManager(), _alias_nullable, _isRemoved, this.StartIndex, this.PageSize, out count);
					break;
				case ProductSelectMethod.GetByIdIsDisabled:
					_id = ( values["Id"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["Id"], typeof(System.Int64)) : (long)0;
					_isDisabled = ( values["IsDisabled"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsDisabled"], typeof(System.Boolean)) : false;
					item = ProductProvider.GetByIdIsDisabled(GetTransactionManager(), _id, _isDisabled);
					results = new TList<Product>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				case ProductSelectMethod.GetByIdIsDisabledIsRemoved:
					_id = ( values["Id"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["Id"], typeof(System.Int64)) : (long)0;
					_isDisabled = ( values["IsDisabled"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsDisabled"], typeof(System.Boolean)) : false;
					_isRemoved = ( values["IsRemoved"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsRemoved"], typeof(System.Boolean)) : false;
					item = ProductProvider.GetByIdIsDisabledIsRemoved(GetTransactionManager(), _id, _isDisabled, _isRemoved);
					results = new TList<Product>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				case ProductSelectMethod.GetByIdIsRemoved:
					_id = ( values["Id"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["Id"], typeof(System.Int64)) : (long)0;
					_isRemoved = ( values["IsRemoved"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsRemoved"], typeof(System.Boolean)) : false;
					item = ProductProvider.GetByIdIsRemoved(GetTransactionManager(), _id, _isRemoved);
					results = new TList<Product>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				case ProductSelectMethod.GetByIdLanguage:
					_id = ( values["Id"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["Id"], typeof(System.Int64)) : (long)0;
					_language = ( values["Language"] != null ) ? (System.String) EntityUtil.ChangeType(values["Language"], typeof(System.String)) : "N'vn'";
					item = ProductProvider.GetByIdLanguage(GetTransactionManager(), _id, _language);
					results = new TList<Product>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				case ProductSelectMethod.GetByIdLanguageIsDisabled:
					_id = ( values["Id"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["Id"], typeof(System.Int64)) : (long)0;
					_language = ( values["Language"] != null ) ? (System.String) EntityUtil.ChangeType(values["Language"], typeof(System.String)) : "N'vn'";
					_isDisabled = ( values["IsDisabled"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsDisabled"], typeof(System.Boolean)) : false;
					item = ProductProvider.GetByIdLanguageIsDisabled(GetTransactionManager(), _id, _language, _isDisabled);
					results = new TList<Product>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				case ProductSelectMethod.GetByIdLanguageIsDisabledIsRemoved:
					_id = ( values["Id"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["Id"], typeof(System.Int64)) : (long)0;
					_language = ( values["Language"] != null ) ? (System.String) EntityUtil.ChangeType(values["Language"], typeof(System.String)) : "N'vn'";
					_isDisabled = ( values["IsDisabled"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsDisabled"], typeof(System.Boolean)) : false;
					_isRemoved = ( values["IsRemoved"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsRemoved"], typeof(System.Boolean)) : false;
					item = ProductProvider.GetByIdLanguageIsDisabledIsRemoved(GetTransactionManager(), _id, _language, _isDisabled, _isRemoved);
					results = new TList<Product>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				case ProductSelectMethod.GetByIdLanguageIsRemoved:
					_id = ( values["Id"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["Id"], typeof(System.Int64)) : (long)0;
					_language = ( values["Language"] != null ) ? (System.String) EntityUtil.ChangeType(values["Language"], typeof(System.String)) : "N'vn'";
					_isRemoved = ( values["IsRemoved"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsRemoved"], typeof(System.Boolean)) : false;
					item = ProductProvider.GetByIdLanguageIsRemoved(GetTransactionManager(), _id, _language, _isRemoved);
					results = new TList<Product>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				case ProductSelectMethod.GetByIdOriginalId:
					_id = ( values["Id"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["Id"], typeof(System.Int64)) : (long)0;
					_originalId = ( values["OriginalId"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["OriginalId"], typeof(System.Int64)) : (long)0;
					item = ProductProvider.GetByIdOriginalId(GetTransactionManager(), _id, _originalId);
					results = new TList<Product>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				case ProductSelectMethod.GetByIdOriginalIdIsDisabled:
					_id = ( values["Id"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["Id"], typeof(System.Int64)) : (long)0;
					_originalId = ( values["OriginalId"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["OriginalId"], typeof(System.Int64)) : (long)0;
					_isDisabled = ( values["IsDisabled"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsDisabled"], typeof(System.Boolean)) : false;
					item = ProductProvider.GetByIdOriginalIdIsDisabled(GetTransactionManager(), _id, _originalId, _isDisabled);
					results = new TList<Product>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				case ProductSelectMethod.GetByIdOriginalIdIsDisabledIsRemoved:
					_id = ( values["Id"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["Id"], typeof(System.Int64)) : (long)0;
					_originalId = ( values["OriginalId"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["OriginalId"], typeof(System.Int64)) : (long)0;
					_isDisabled = ( values["IsDisabled"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsDisabled"], typeof(System.Boolean)) : false;
					_isRemoved = ( values["IsRemoved"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsRemoved"], typeof(System.Boolean)) : false;
					item = ProductProvider.GetByIdOriginalIdIsDisabledIsRemoved(GetTransactionManager(), _id, _originalId, _isDisabled, _isRemoved);
					results = new TList<Product>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				case ProductSelectMethod.GetByIdOriginalIdIsRemoved:
					_id = ( values["Id"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["Id"], typeof(System.Int64)) : (long)0;
					_originalId = ( values["OriginalId"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["OriginalId"], typeof(System.Int64)) : (long)0;
					_isRemoved = ( values["IsRemoved"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsRemoved"], typeof(System.Boolean)) : false;
					item = ProductProvider.GetByIdOriginalIdIsRemoved(GetTransactionManager(), _id, _originalId, _isRemoved);
					results = new TList<Product>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				case ProductSelectMethod.GetByLanguage:
					_language = ( values["Language"] != null ) ? (System.String) EntityUtil.ChangeType(values["Language"], typeof(System.String)) : "N'vn'";
					results = ProductProvider.GetByLanguage(GetTransactionManager(), _language, this.StartIndex, this.PageSize, out count);
					break;
				case ProductSelectMethod.GetByLanguageIsDisabled:
					_language = ( values["Language"] != null ) ? (System.String) EntityUtil.ChangeType(values["Language"], typeof(System.String)) : "N'vn'";
					_isDisabled = ( values["IsDisabled"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsDisabled"], typeof(System.Boolean)) : false;
					results = ProductProvider.GetByLanguageIsDisabled(GetTransactionManager(), _language, _isDisabled, this.StartIndex, this.PageSize, out count);
					break;
				case ProductSelectMethod.GetByLanguageIsDisabledIsRemoved:
					_language = ( values["Language"] != null ) ? (System.String) EntityUtil.ChangeType(values["Language"], typeof(System.String)) : "N'vn'";
					_isDisabled = ( values["IsDisabled"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsDisabled"], typeof(System.Boolean)) : false;
					_isRemoved = ( values["IsRemoved"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsRemoved"], typeof(System.Boolean)) : false;
					results = ProductProvider.GetByLanguageIsDisabledIsRemoved(GetTransactionManager(), _language, _isDisabled, _isRemoved, this.StartIndex, this.PageSize, out count);
					break;
				case ProductSelectMethod.GetByLanguageIsRemoved:
					_language = ( values["Language"] != null ) ? (System.String) EntityUtil.ChangeType(values["Language"], typeof(System.String)) : "N'vn'";
					_isRemoved = ( values["IsRemoved"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsRemoved"], typeof(System.Boolean)) : false;
					results = ProductProvider.GetByLanguageIsRemoved(GetTransactionManager(), _language, _isRemoved, this.StartIndex, this.PageSize, out count);
					break;
				case ProductSelectMethod.GetByMenuAlias:
					_menuAlias_nullable = (System.String) EntityUtil.ChangeType(values["MenuAlias"], typeof(System.String));
					results = ProductProvider.GetByMenuAlias(GetTransactionManager(), _menuAlias_nullable, this.StartIndex, this.PageSize, out count);
					break;
				case ProductSelectMethod.GetByMenuAliasIsDisabled:
					_menuAlias_nullable = (System.String) EntityUtil.ChangeType(values["MenuAlias"], typeof(System.String));
					_isDisabled = ( values["IsDisabled"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsDisabled"], typeof(System.Boolean)) : false;
					results = ProductProvider.GetByMenuAliasIsDisabled(GetTransactionManager(), _menuAlias_nullable, _isDisabled, this.StartIndex, this.PageSize, out count);
					break;
				case ProductSelectMethod.GetByMenuAliasIsDisabledIsRemoved:
					_menuAlias_nullable = (System.String) EntityUtil.ChangeType(values["MenuAlias"], typeof(System.String));
					_isDisabled = ( values["IsDisabled"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsDisabled"], typeof(System.Boolean)) : false;
					_isRemoved = ( values["IsRemoved"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsRemoved"], typeof(System.Boolean)) : false;
					results = ProductProvider.GetByMenuAliasIsDisabledIsRemoved(GetTransactionManager(), _menuAlias_nullable, _isDisabled, _isRemoved, this.StartIndex, this.PageSize, out count);
					break;
				case ProductSelectMethod.GetByMenuAliasIsRemoved:
					_menuAlias_nullable = (System.String) EntityUtil.ChangeType(values["MenuAlias"], typeof(System.String));
					_isRemoved = ( values["IsRemoved"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsRemoved"], typeof(System.Boolean)) : false;
					results = ProductProvider.GetByMenuAliasIsRemoved(GetTransactionManager(), _menuAlias_nullable, _isRemoved, this.StartIndex, this.PageSize, out count);
					break;
				case ProductSelectMethod.GetByMenuId:
					_menuId = ( values["MenuId"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["MenuId"], typeof(System.Int64)) : (long)0;
					results = ProductProvider.GetByMenuId(GetTransactionManager(), _menuId, this.StartIndex, this.PageSize, out count);
					break;
				case ProductSelectMethod.GetByMenuIdIsDisabled:
					_menuId = ( values["MenuId"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["MenuId"], typeof(System.Int64)) : (long)0;
					_isDisabled = ( values["IsDisabled"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsDisabled"], typeof(System.Boolean)) : false;
					results = ProductProvider.GetByMenuIdIsDisabled(GetTransactionManager(), _menuId, _isDisabled, this.StartIndex, this.PageSize, out count);
					break;
				case ProductSelectMethod.GetByMenuIdIsDisabledIsRemoved:
					_menuId = ( values["MenuId"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["MenuId"], typeof(System.Int64)) : (long)0;
					_isDisabled = ( values["IsDisabled"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsDisabled"], typeof(System.Boolean)) : false;
					_isRemoved = ( values["IsRemoved"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsRemoved"], typeof(System.Boolean)) : false;
					results = ProductProvider.GetByMenuIdIsDisabledIsRemoved(GetTransactionManager(), _menuId, _isDisabled, _isRemoved, this.StartIndex, this.PageSize, out count);
					break;
				case ProductSelectMethod.GetByMenuIdIsRemoved:
					_menuId = ( values["MenuId"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["MenuId"], typeof(System.Int64)) : (long)0;
					_isRemoved = ( values["IsRemoved"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsRemoved"], typeof(System.Boolean)) : false;
					results = ProductProvider.GetByMenuIdIsRemoved(GetTransactionManager(), _menuId, _isRemoved, this.StartIndex, this.PageSize, out count);
					break;
				case ProductSelectMethod.GetByMenuIdLanguage:
					_menuId = ( values["MenuId"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["MenuId"], typeof(System.Int64)) : (long)0;
					_language = ( values["Language"] != null ) ? (System.String) EntityUtil.ChangeType(values["Language"], typeof(System.String)) : "N'vn'";
					results = ProductProvider.GetByMenuIdLanguage(GetTransactionManager(), _menuId, _language, this.StartIndex, this.PageSize, out count);
					break;
				case ProductSelectMethod.GetByMenuIdLanguageIsDisabled:
					_menuId = ( values["MenuId"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["MenuId"], typeof(System.Int64)) : (long)0;
					_language = ( values["Language"] != null ) ? (System.String) EntityUtil.ChangeType(values["Language"], typeof(System.String)) : "N'vn'";
					_isDisabled = ( values["IsDisabled"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsDisabled"], typeof(System.Boolean)) : false;
					results = ProductProvider.GetByMenuIdLanguageIsDisabled(GetTransactionManager(), _menuId, _language, _isDisabled, this.StartIndex, this.PageSize, out count);
					break;
				case ProductSelectMethod.GetByMenuIdLanguageIsDisabledIsRemoved:
					_menuId = ( values["MenuId"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["MenuId"], typeof(System.Int64)) : (long)0;
					_language = ( values["Language"] != null ) ? (System.String) EntityUtil.ChangeType(values["Language"], typeof(System.String)) : "N'vn'";
					_isDisabled = ( values["IsDisabled"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsDisabled"], typeof(System.Boolean)) : false;
					_isRemoved = ( values["IsRemoved"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsRemoved"], typeof(System.Boolean)) : false;
					results = ProductProvider.GetByMenuIdLanguageIsDisabledIsRemoved(GetTransactionManager(), _menuId, _language, _isDisabled, _isRemoved, this.StartIndex, this.PageSize, out count);
					break;
				case ProductSelectMethod.GetByMenuIdLanguageIsRemoved:
					_menuId = ( values["MenuId"] != null ) ? (System.Int64) EntityUtil.ChangeType(values["MenuId"], typeof(System.Int64)) : (long)0;
					_language = ( values["Language"] != null ) ? (System.String) EntityUtil.ChangeType(values["Language"], typeof(System.String)) : "N'vn'";
					_isRemoved = ( values["IsRemoved"] != null ) ? (System.Boolean) EntityUtil.ChangeType(values["IsRemoved"], typeof(System.Boolean)) : false;
					results = ProductProvider.GetByMenuIdLanguageIsRemoved(GetTransactionManager(), _menuId, _language, _isRemoved, this.StartIndex, this.PageSize, out count);
					break;
				// FK
				// M:M
				// Custom
				default:
					break;
			}

			if ( results != null && count < 1 )
			{
				count = results.Count;

				if ( !String.IsNullOrEmpty(CustomMethodRecordCountParamName) )
				{
					object objCustomCount = EntityUtil.ChangeType(customOutput[CustomMethodRecordCountParamName], typeof(Int32));
					
					if ( objCustomCount != null )
					{
						count = (int) objCustomCount;
					}
				}
			}
			
			return results;
		}
		
		/// <summary>
		/// Gets the values of any supplied parameters for internal caching.
		/// </summary>
		/// <param name="values">An IDictionary object of name/value pairs.</param>
		protected override void GetSelectParameters(IDictionary values)
		{
			if ( SelectMethod == ProductSelectMethod.Get || SelectMethod == ProductSelectMethod.GetById )
			{
				EntityId = GetEntityKey(values);
			}
		}

		/// <summary>
		/// Performs a DeepLoad operation for the current entity if it has
		/// not already been performed.
		/// </summary>
		internal override void DeepLoad()
		{
			if ( !IsDeepLoaded )
			{
				Product entity = GetCurrentEntity();
				
				if ( entity != null )
				{
					// execute deep load method
					ProductProvider.DeepLoad(GetTransactionManager(), GetCurrentEntity(), EnableRecursiveDeepLoad);
					// set loaded flag
					IsDeepLoaded = true;
				}
			}
		}

		/// <summary>
		/// Performs a DeepLoad operation on the specified entity collection.
		/// </summary>
		/// <param name="entityList"></param>
		/// <param name="properties"></param>
		internal override void DeepLoad(TList<Product> entityList, ProviderDataSourceDeepLoadList properties)
		{
			// execute deep load method
			ProductProvider.DeepLoad(GetTransactionManager(), entityList, properties.Recursive, properties.Method, properties.GetTypes());
		}

		#endregion Select Methods
	}
	
	#region ProductDataSourceDesigner

	/// <summary>
	/// Provides design-time support in a design host for the ProductDataSource class.
	/// </summary>
	public class ProductDataSourceDesigner : ProviderDataSourceDesigner<Product, ProductKey>
	{
		/// <summary>
		/// Initializes a new instance of the ProductDataSourceDesigner class.
		/// </summary>
		public ProductDataSourceDesigner()
		{
		}

		/// <summary>
		/// Gets or sets the SelectMethod property.
		/// </summary>
		public ProductSelectMethod SelectMethod
		{
			get { return ((ProductDataSource) DataSource).SelectMethod; }
			set { SetPropertyValue("SelectMethod", value); }
		}

		/// <summary>Gets the designer action list collection for this designer.</summary>
		/// <returns>The <see cref="T:System.ComponentModel.Design.DesignerActionListCollection"/>
		/// associated with this designer.</returns>
		public override DesignerActionListCollection ActionLists
		{
			get
			{
				DesignerActionListCollection actions = new DesignerActionListCollection();
				actions.Add(new ProductDataSourceActionList(this));
				actions.AddRange(base.ActionLists);
				return actions;
			}
		}
	}

	#region ProductDataSourceActionList

	/// <summary>
	/// Supports the ProductDataSourceDesigner class.
	/// </summary>
	internal class ProductDataSourceActionList : DesignerActionList
	{
		private ProductDataSourceDesigner _designer;

		/// <summary>
		/// Initializes a new instance of the ProductDataSourceActionList class.
		/// </summary>
		/// <param name="designer"></param>
		public ProductDataSourceActionList(ProductDataSourceDesigner designer) : base(designer.Component)
		{
			_designer = designer;
		}

		/// <summary>
		/// Gets or sets the SelectMethod property.
		/// </summary>
		public ProductSelectMethod SelectMethod
		{
			get { return _designer.SelectMethod; }
			set { _designer.SelectMethod = value; }
		}

		/// <summary>
		/// Returns the collection of <see cref="T:System.ComponentModel.Design.DesignerActionItem"/>
		/// objects contained in the list.
		/// </summary>
		/// <returns>A <see cref="T:System.ComponentModel.Design.DesignerActionItem"/>
		/// array that contains the items in this list.</returns>
		public override DesignerActionItemCollection GetSortedActionItems()
		{
			DesignerActionItemCollection items = new DesignerActionItemCollection();
			items.Add(new DesignerActionPropertyItem("SelectMethod", "Select Method", "Methods"));
			return items;
		}
	}

	#endregion ProductDataSourceActionList
	
	#endregion ProductDataSourceDesigner
	
	#region ProductSelectMethod
	
	/// <summary>
	/// Enumeration of method names available for the ProductDataSource.SelectMethod property.
	/// </summary>
	public enum ProductSelectMethod
	{
		/// <summary>
		/// Represents the Get method.
		/// </summary>
		Get,
		/// <summary>
		/// Represents the GetAll method.
		/// </summary>
		GetAll,
		/// <summary>
		/// Represents the GetPaged method.
		/// </summary>
		GetPaged,
		/// <summary>
		/// Represents the Find method.
		/// </summary>
		Find,
		/// <summary>
		/// Represents the GetByAlias method.
		/// </summary>
		GetByAlias,
		/// <summary>
		/// Represents the GetByAliasIsDisabled method.
		/// </summary>
		GetByAliasIsDisabled,
		/// <summary>
		/// Represents the GetByAliasIsDisabledIsRemoved method.
		/// </summary>
		GetByAliasIsDisabledIsRemoved,
		/// <summary>
		/// Represents the GetByAliasIsRemoved method.
		/// </summary>
		GetByAliasIsRemoved,
		/// <summary>
		/// Represents the GetByIdIsDisabled method.
		/// </summary>
		GetByIdIsDisabled,
		/// <summary>
		/// Represents the GetByIdIsDisabledIsRemoved method.
		/// </summary>
		GetByIdIsDisabledIsRemoved,
		/// <summary>
		/// Represents the GetByIdIsRemoved method.
		/// </summary>
		GetByIdIsRemoved,
		/// <summary>
		/// Represents the GetByIdLanguage method.
		/// </summary>
		GetByIdLanguage,
		/// <summary>
		/// Represents the GetByIdLanguageIsDisabled method.
		/// </summary>
		GetByIdLanguageIsDisabled,
		/// <summary>
		/// Represents the GetByIdLanguageIsDisabledIsRemoved method.
		/// </summary>
		GetByIdLanguageIsDisabledIsRemoved,
		/// <summary>
		/// Represents the GetByIdLanguageIsRemoved method.
		/// </summary>
		GetByIdLanguageIsRemoved,
		/// <summary>
		/// Represents the GetByIdOriginalId method.
		/// </summary>
		GetByIdOriginalId,
		/// <summary>
		/// Represents the GetByIdOriginalIdIsDisabled method.
		/// </summary>
		GetByIdOriginalIdIsDisabled,
		/// <summary>
		/// Represents the GetByIdOriginalIdIsDisabledIsRemoved method.
		/// </summary>
		GetByIdOriginalIdIsDisabledIsRemoved,
		/// <summary>
		/// Represents the GetByIdOriginalIdIsRemoved method.
		/// </summary>
		GetByIdOriginalIdIsRemoved,
		/// <summary>
		/// Represents the GetByLanguage method.
		/// </summary>
		GetByLanguage,
		/// <summary>
		/// Represents the GetByLanguageIsDisabled method.
		/// </summary>
		GetByLanguageIsDisabled,
		/// <summary>
		/// Represents the GetByLanguageIsDisabledIsRemoved method.
		/// </summary>
		GetByLanguageIsDisabledIsRemoved,
		/// <summary>
		/// Represents the GetByLanguageIsRemoved method.
		/// </summary>
		GetByLanguageIsRemoved,
		/// <summary>
		/// Represents the GetByMenuAlias method.
		/// </summary>
		GetByMenuAlias,
		/// <summary>
		/// Represents the GetByMenuAliasIsDisabled method.
		/// </summary>
		GetByMenuAliasIsDisabled,
		/// <summary>
		/// Represents the GetByMenuAliasIsDisabledIsRemoved method.
		/// </summary>
		GetByMenuAliasIsDisabledIsRemoved,
		/// <summary>
		/// Represents the GetByMenuAliasIsRemoved method.
		/// </summary>
		GetByMenuAliasIsRemoved,
		/// <summary>
		/// Represents the GetByMenuId method.
		/// </summary>
		GetByMenuId,
		/// <summary>
		/// Represents the GetByMenuIdIsDisabled method.
		/// </summary>
		GetByMenuIdIsDisabled,
		/// <summary>
		/// Represents the GetByMenuIdIsDisabledIsRemoved method.
		/// </summary>
		GetByMenuIdIsDisabledIsRemoved,
		/// <summary>
		/// Represents the GetByMenuIdIsRemoved method.
		/// </summary>
		GetByMenuIdIsRemoved,
		/// <summary>
		/// Represents the GetByMenuIdLanguage method.
		/// </summary>
		GetByMenuIdLanguage,
		/// <summary>
		/// Represents the GetByMenuIdLanguageIsDisabled method.
		/// </summary>
		GetByMenuIdLanguageIsDisabled,
		/// <summary>
		/// Represents the GetByMenuIdLanguageIsDisabledIsRemoved method.
		/// </summary>
		GetByMenuIdLanguageIsDisabledIsRemoved,
		/// <summary>
		/// Represents the GetByMenuIdLanguageIsRemoved method.
		/// </summary>
		GetByMenuIdLanguageIsRemoved,
		/// <summary>
		/// Represents the GetById method.
		/// </summary>
		GetById
	}
	
	#endregion ProductSelectMethod

	#region ProductFilter
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="SqlFilter&lt;EntityColumn&gt;"/> class
	/// that is used exclusively with a <see cref="Product"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class ProductFilter : SqlFilter<ProductColumn>
	{
	}
	
	#endregion ProductFilter

	#region ProductExpressionBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="SqlExpressionBuilder&lt;EntityColumn&gt;"/> class
	/// that is used exclusively with a <see cref="Product"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class ProductExpressionBuilder : SqlExpressionBuilder<ProductColumn>
	{
	}
	
	#endregion ProductExpressionBuilder	

	#region ProductProperty
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="ChildEntityProperty&lt;ProductChildEntityTypes&gt;"/> class
	/// that is used exclusively with a <see cref="Product"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class ProductProperty : ChildEntityProperty<ProductChildEntityTypes>
	{
	}
	
	#endregion ProductProperty
}

